<template>
    <div>欢迎 {{allUserType[type - 1].label}} : {{ user }} 正在跳转...</div>
</template>

<script>
import { mapState } from 'pinia';
import { useUserStore } from '../../store/user';
import { useRouter } from 'vue-router';
import { allUserType } from '../../select/user';
import { delay } from "@/utils"

export default {
    setup() {
        const router = useRouter();
        const user = useUserStore();
        Promise.resolve(user.type).then(async (type) => {
            await delay(1000);
            if (type === 8) { // 平台超级管理员
                router.push({
                    name: "addUser"
                })
            } else if (type === 12) { // 用户
                router.push({
                    name: "Home"
                })
            } else if (type === 4) { // 注册用户审核人员
                router.push({
                    name: "UserAudit"
                })
            } else if (type === 5) { // 交易审核人员
                router.push({
                    name: "TransactionAuditList"
                })
            } else if (type === 3) { // 资讯编辑人员
                router.push({
                    name: "AnnouncementAdd"
                })
            } else if (type === 6) { // 资讯审核人员
                router.push({
                    name: "AnnouncementVerify"
                })
            } else if (type === 7) { // 资讯维护人员
                router.push({
                    name: "AnnouncementVerify"
                })
            }
        });
        return {
            allUserType,
        }
    },
    computed: {
        ...mapState(useUserStore, ["type", "user"])
    }
}
</script>

<style>

</style>